package cn.xutongxue.book_sales.untils;

import cn.hutool.core.date.DateUnit;
import cn.hutool.core.util.RandomUtil;
import lombok.Data;
import org.springframework.stereotype.Component;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;


/**
 * Created By TongXue Xu on 2021/12/24 15:34
 */
@Component
public class OrderUtils {

    public String getOrderNumber() {
        Date date = new Date();
        SimpleDateFormat dateFormat= new SimpleDateFormat("yyyyMMddhhmmss");
        String time = dateFormat.format(date);
        String randomString = RandomUtil.randomNumbers(9);
        String orderNumber = "XTX" + time + randomString;
        return orderNumber;
    }

}
